package com.toma.booking.ajax;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;

import com.toma.booking.dto.BoardDto;
import com.toma.booking.dto.MemberDto;
import com.toma.booking.model.MemberManager;
import com.toma.booking.model.MemberService;
public class MemberAjaxServlet extends HttpServlet {
 private static final long serialVersionUID = 1L;
    public void doGet(HttpServletRequest request, 
      HttpServletResponse response) throws ServletException, IOException {
     doPost(request,response);
 }
    public void doPost(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
     request.setCharacterEncoding("euc-kr");
     response.setContentType("text/json; charset=euc-kr");
     MemberService service = MemberService.getInstance();
     
     MemberManager manager=new MemberManager();
  //System.out.println(request.getParameter("id"));
  
     //String id=request.getParameter("id");
  String email = request.getParameter("email");
     System.out.println("1: email=  "+email);
  //MembersDto dto =manager.getCustUser( id);
  int count = service.email_dpc(email);  
  Map<String, Integer> map = new HashMap<String, Integer>();
  map.put("count", count);
  System.out.println("2: count=  "+count);
  JSONObject jsonObject = JSONObject.fromObject(map);
  System.out.println("3: "+jsonObject.toString());
  PrintWriter pr= response.getWriter();
  jsonObject.write(pr);
 }
}